package org.dubnation.auth.service.impl;

import org.dubnation.auth.domain.Role;
import org.dubnation.auth.domain.RoleDTO;
import org.dubnation.auth.mapper.RoleMapper;
import org.dubnation.auth.service.IRoleService;
import org.dubnation.base.service.impl.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhu
 * @since 2023-10-16
 */
@Service
@Transactional(propagation = Propagation.SUPPORTS,readOnly = true)
public class RoleServiceImpl extends BaseServiceImpl<Role> implements IRoleService {

    @Autowired
    private RoleMapper mapper;

    @Transactional
    @Override
    public void insertRolePermission(RoleDTO roleDTO) {
        //清空角色权限表
        mapper.deleteAll(roleDTO);
        //权限数据入库
        mapper.insertRolePermission(roleDTO);
    }

    @Override
    public List<Long> queryRolePermissionIds(Long id) {
        return mapper.queryRolePermissionIds(id);
    }
}
